package org.yxt.springcloud.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.yxt.springcloud.entities.CommonResult;
import org.yxt.springcloud.service.StorageService;

@RestController
@RequestMapping(value = "storage")
public class StorageController {
    @Autowired
    private StorageService storageService;

    /**
     * 减去库存
     *
     * @param productId
     * @param count
     * @return
     */
    @PostMapping(value = "decrease")
    public CommonResult decrease(@RequestParam("productId") int productId, @RequestParam("count") int count) {
        storageService.updateDetract(productId, count);
        return new CommonResult(1, "success");
    }
}
